<?php
/**
 * Created by PhpStorm.
 * User: BlueIdeaLirui
 * Date: 2020/02/24
 * Time: 下午2:30
 */

namespace business\base\services;

use common\utils\ScoreUtils;
use yii\db\Query;

class ScoreItemsService
{
    /**
     * 通过分值项获取分值
     * @param $item
     * @return object
     */
    public static function get($item)
    {
        $sore = ScoreUtils::get($item);
        if (empty($sore)) {
            $sore = (new Query())
                ->from('`b2b_search`.`score_sort_items`')
                ->select('score')
                ->where(['item' => $item])
                ->createCommand(\Yii::$app->db)
                ->queryScalar();
            ScoreUtils::set($item, $sore, 600);
        }

        return intval($sore);
    }
}
